class MyArrays<T> {
    public T[] objects = (T[])new Object[10];

    // 给数组添加元素
    public void setVal (int pos, T val) {
        objects[pos] = val;
    }

    // 返回数组中某个下标的值
    public T getVal (int pos) {
        return objects[pos];
    }
}

public class Work {

    public static void main(String[] args) {
        // 此时指定的是 Integer 类型，只能传递整数
        MyArrays<Integer> myArrays = new MyArrays<Integer>();
        myArrays.setVal(0, 10);
        myArrays.setVal(1, 20);
        //myArrays.setVal(2, "helllo");
        //myArrays.setVal(3, 'b');
        //myArrays.setVal(4, 10.10);

        int ret = myArrays.getVal(1);

        MyArrays<String> myArrays1 = new MyArrays<String>();
        myArrays1.setVal(2, "hello");
        myArrays1.setVal(3, "world");
        String retString = myArrays1.getVal(2);

        //System.out.println(ret);
        System.out.println(retString);
    }
}
